package com.ruoyi.carShop.controller;

import com.ruoyi.carShop.mapper.OrderEvaluationMapper1;
import com.ruoyi.carShop.service.LoadService;
import com.ruoyi.system.api.domain.OrderEvaluation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.context.request.RequestAttributes;
import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;

import javax.servlet.http.HttpServletRequest;

import java.util.List;

@CrossOrigin
@RestController
@RequestMapping("/carShop")
public class OrderEvaluationController1 {
    @Autowired
    private LoadService loadService;
    @Autowired
    private OrderEvaluationMapper1 orderEvaluationMapper1;
    @RequestMapping("/orderEvaluation/list")
    public List<OrderEvaluation> queryOrderEvaluation(OrderEvaluation orderEvaluation) {
        RequestAttributes attributes = RequestContextHolder.getRequestAttributes();
        ServletRequestAttributes sra = (ServletRequestAttributes)attributes;
        HttpServletRequest request = sra.getRequest();
        //2 从请求头获取token
        String token = request.getHeader("token");
        int mId = loadService.getToken(token);
        orderEvaluation.setSeller(mId);
        return orderEvaluationMapper1.queryOrderEvaluation(orderEvaluation);
    }
    @RequestMapping("/orderEvaluation/listByOrderId")
    public OrderEvaluation queryOrderEvaluationByOrderId(Integer id) {
        return orderEvaluationMapper1.queryOrderEvaluationByOrderId(id);
    }
    @RequestMapping("/orderEvaluation/queryOrderEvaluation1")
    public OrderEvaluation queryOrderEvaluation1(Integer id) {
        return orderEvaluationMapper1.queryOrderEvaluation1(id);
    }
    @RequestMapping("/orderEvaluation/queryOrderEvaluation2")
    public List<OrderEvaluation> queryOrderEvaluation2(Integer id) {
        return orderEvaluationMapper1.queryOrderEvaluation2(id);
    }
}

